package com.sky.config;

import com.sky.properties.AliOssProperties;
import com.sky.utils.AliOssUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Slf4j
@Configuration // 表示当前类是一个配置类
public class OssConfiguration {
    @Bean // 表示当前方法的返回值是一个bean对象，bean对象会自动注入到容器中
    public AliOssUtil aliOssUtil(AliOssProperties aliOssProperties) { // 初始化AliOssUtil对象
        log.info("初始化AliOssUtil对象：{}",aliOssProperties);
        String endpoint = aliOssProperties.getEndpoint();
        String accessKeyId = aliOssProperties.getAccessKeyId();
        String accessKeySecret = aliOssProperties.getAccessKeySecret();
        String bucketName = aliOssProperties.getBucketName();

        return new AliOssUtil(endpoint, accessKeyId, accessKeySecret, bucketName);
    }
}
